<template>
  <div class="song-request-page">
    <div class="header-bar">
      <div class="back-button" @click="goBack">
        <el-icon><ArrowLeft /></el-icon>
      </div>
      <div class="page-title">歌曲请求</div>
      <div class="placeholder"></div>
    </div>
    
    <div class="content">
      <div class="form-container">
        <div class="input-group">
          <div class="input-label">歌曲名称</div>
          <input
            type="text"
            class="custom-input"
            v-model="form.songName"
            placeholder="请输入歌曲名称"
          />
        </div>
        
        <div class="input-group">
          <div class="input-label">歌手名称</div>
          <input
            type="text"
            class="custom-input"
            v-model="form.artistName"
            placeholder="请输入歌手名称"
          />
        </div>
        
        <button class="submit-button" @click="submitRequest" :disabled="loading">
          {{ loading ? '提交中...' : '提交请求' }}
        </button>
      </div>
    </div>

    <!-- 自定义确认弹窗 -->
    <div class="custom-dialog-overlay" v-if="showDialog" @click.self="closeDialog">
      <div class="custom-dialog">
        <div class="dialog-header">
          <h3 class="dialog-title">提交成功</h3>
        </div>
        <div class="dialog-content">
          提交成功，后台工作人员将根据歌曲热度、提交顺序、歌曲难度、歌曲风格等因素进行进行挑选后进行更新，更新歌曲制作成本非常高所以无法保证所有提交申请的歌曲都能更新，只能选择部分更新，请您原谅和理解。
        </div>
        <div class="dialog-footer">
          <button class="dialog-btn" @click="closeDialog">知道了</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { ArrowLeft } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import { useRouter } from 'vue-router'

const router = useRouter()
const loading = ref(false)
const showDialog = ref(false)
const form = ref({
  songName: '',
  artistName: ''
})

const submitRequest = () => {
  if (!form.value.songName || !form.value.artistName) {
    ElMessage({
      message: '请填写歌曲名称和歌手名称',
      type: 'warning',
      duration: 2000,
      customClass: 'custom-message'
    })
    return
  }
  
  // 立即显示成功弹窗
  showDialog.value = true
  resetForm()
}

const resetForm = () => {
  form.value = {
    songName: '',
    artistName: ''
  }
}

const closeDialog = () => {
  showDialog.value = false
}

const goBack = () => {
  router.go(-1)
}
</script>

<style scoped>
.song-request-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e1935 0%, #111020 100%);
  color: white;
  padding: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

.header-bar {
  padding-top: max(20px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.back-button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.placeholder {
  width: 36px;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
}

.form-container {
  background-color: rgba(255, 255, 255, 0.05);
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
}

.input-group {
  margin-bottom: 20px;
}

.input-label {
  font-size: 14px;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.9);
}

.custom-input {
  width: 100%;
  height: 50px;
  background-color: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 10px;
  color: white;
  padding: 0 15px;
  font-size: 16px;
  outline: none;
}

.custom-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.submit-button {
  width: 100%;
  height: 54px;
  background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 10px;
}

.submit-button:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.submit-button:disabled {
  opacity: 0.7;
  transform: none;
  cursor: not-allowed;
}

/* 自定义弹窗样式 */
.custom-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(5px);
}

.custom-dialog {
  width: 85%;
  max-width: 420px;
  background: linear-gradient(135deg, #2d2956 0%, #1a1732 100%);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(139, 92, 246, 0.3);
  animation: dialogFadeIn 0.3s ease;
}

@keyframes dialogFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dialog-header {
  padding: 20px 24px 0;
  text-align: center;
}

.dialog-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  text-align: center;
}

.dialog-content {
  padding: 16px 24px;
  font-size: 15px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
  text-align: center;
}

.dialog-footer {
  padding: 0 24px 24px;
  display: flex;
  justify-content: center;
}

.dialog-btn {
  min-width: 120px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dialog-btn:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}
</style> 